<template>
  <a-spin :spinning="loading">
    <a-card style="margin-top: 12px" :bordered="true" title="奖励荣誉">
      <div slot="extra">
        总分: <i style='font-style: normal;color: rgba(0, 0, 0, 0.85);font-weight: 500;font-size: 16px;'>{{ score.score }}</i>
        <a-button style="margin-left: 20px" :icon="this.getIconShow" @click="showButtomShow"> {{ this.getButtomShow }}</a-button>
      </div>
      <div>
        <a-list size="small"  v-show="isShow">
          <result-list-item-honour v-for="(item,index) in items" :key="index" :data="item"></result-list-item-honour>
        </a-list>
      </div>
      <template slot="actions"  v-if="teacherType=='1-1'">
        <teacher-result-ranking :schoolRanking="schoolRanking" :schoolTotal="teacherCount.schoolTeacherCount" :depRanking="depRanking" :depTotal="teacherCount.orgTeacherCount"></teacher-result-ranking>
      </template>
    </a-card>
  </a-spin>
</template>

<script>

import teacherResultRanking from '@views/gfxy/result/modules/teacherResultRanking'
import ResultListItemHonour from '@views/gfxy/result/modules/ResultListItemHonour'
import { getAction } from '@api/manage'

export default {
  name: 'teacherResultHonour',
  components: { ResultListItemHonour,teacherResultRanking, },
  props: {
    userName: {
      type: String,
      required: true
    },
    date: {
      type: String,
      required: true
    },
    teacherCount:{
      type: Object,
      required: true
    },
    score:{
      type: Object,
      required: true
    },
    teacherType:{
      type:String,
      required: true
    }
  },
  data(){
    return {
      isShow:false,
      url: {
        detail: '/honour/honourCommon/honourProjectsResult',
      },
      totalInfo:{},
      items: [],
      loading: false,
    }
  },
  computed:{
    getButtomShow(){
      if(this.isShow){
        return "隐藏详情"
      } else {
        return "显示详情"
      }
    },
    getIconShow(){
      if(this.isShow){
        return "up-circle"
      } else {
        return "down-circle"
      }
    },
    schoolRanking(){
      if(this.score.score == 0){
        return this.teacherCount.schoolTeacherCount
      } else {
        return this.score.shcoolRanked
      }
    },
    depRanking(){
      if(this.score.score == 0){
        return this.teacherCount.orgTeacherCount
      } else {
        return this.score.orgRanked
      }
    }
  },
  methods: {
    showButtomShow(){
      this.isShow = !this.isShow
    },
    load()
    {
      this.loading = true;
      getAction(this.url.detail ,{workNo:this.userName, date:this.date}).then((res)=>{
        console.log(res)
        if(res.success){
          this.items = res.result;

        }else{
          this.$message.warning(res.message);
        }
        this.loading = false;
      }).finally(() => {

      })
    },

  },
  mounted() {

    this.load();
  }

}
</script>

<style lang="less" scoped>
</style>